//package com.example.demo.config;
//
//import org.springframework.amqp.core.*;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.amqp.support.converter.MessageConverter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.Resource;
//import java.util.HashMap;
//import java.util.Map;
//
//@Configuration
//public class Config {
//
//    /**
//     * 创建死信队列
//     * @return
//     */
//    @Bean
//    public Queue deadQueue() {
//        return QueueBuilder.durable("dead.queue").lazy().build();
//    }
//    //死信队列交换机
//    @Bean
//    public DirectExchange deadExchange() {
//        return ExchangeBuilder.directExchange("dead.exchange").build();
//    }
//
//    @Bean
//    public Binding deadBinding(Queue deadQueue, DirectExchange deadExchange) {
//        return BindingBuilder.bind(deadQueue).to(deadExchange).with("dead.routing.key");
//    }
//
//
//    //普通队列（延时队列）
//    @Bean
//    public Queue Queue() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-message-ttl", 5000);//超时时间 单位毫秒
//        args.put("x-dead-letter-exchange", "dead.exchange");//设置死信交换机
//        args.put("x-dead-letter-routing-key", "dead.routing.key");//发送消息的路由
//        args.put("x-max-length", 5);//最大长度
//        return QueueBuilder.durable("buka").withArguments(args).build();
//    }
//
//    @Bean
//    public DirectExchange exchange() {
//        return ExchangeBuilder.directExchange("buka.exchange").build();
//    }
//
//    @Bean
//    public Binding binding(Queue Queue, DirectExchange exchange) {
//        return BindingBuilder.bind(Queue).to(exchange).with("buka.routing.key");
//    }
//
//    @Resource
//    RabbitTemplate rabbitTemplate;
//    @Bean
//    public MessageConverter messageConverter() {
////        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
//        return new Jackson2JsonMessageConverter();
//    }
//
//}
